<template>
  <div>
    <VolBox :model.sync="modelXQ" title="拉取产品" :width="400">
      <VolForm
        ref="formRules1"
        :label-width="100"
        :formFields="formFields1"
        :formRules="formRules1"
      >
      </VolForm>
      <div slot="footer">
        <Button type="success" @click="submit1">确定</Button>
        <Button @click="modelXQ = false">关闭</Button>
      </div>
    </VolBox>
  </div>
</template>
<script>
import VolBox from "@/components/basic/VolBox.vue";
import VolForm from "@/components/basic/VolForm.vue";
var vueParam = {
  components: {
    VolBox,
    VolForm
  },
  data() {
    return {
      modelXQ: false,
      formFields1: {
        supplierCode: ""
      },
      formRules1: [
        [
          {
            title: "供应商",
            field: "supplierCode",
            type: "select",
            dataKey: "",
            data: [],
            required: true
          }
        ]
      ]
    };
  },
  methods: {
    getFormOption(field) {
      let option;
      this.formRules1.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        });
      });
      return option;
    },
    open() {
      this.modelXQ = true;
      let supplierCode = this.getFormOption("supplierCode");
      this.http
        .post("/api/Dictionary/GetVueDictionary", ["mall_supplier"])
        .then(res => {
          if (res[0].dicNo == "mall_supplier") {
            supplierCode.data = res[0].data;
          }
        });
    },
    submit1() {
      this.http
        .post("/api/Products/SyncSupplierProduct", this.formFields1)
        .then(res => {
          if (res.status) {
            this.modelXQ = false;
          } else {
            this.modelXQ = true;
            this.$Message.error(res.message);
          }
        });
    }
  }
};
export default vueParam;
</script>
